package com.zjlp.seproject.mapper;

import com.zjlp.seproject.pojo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
public interface UserMapper {
    List<User> selectAll();

    int deleteByPrimaryKey(Integer id);

    int insert(User record);

    User selectByPrimaryKey(Integer id);

    int updateByPrimaryKey(User record);

    @Select("select * from user where username = #{username} and password = #{password}")
    User login(User user);

    @Select("insert into user(username, password, avatar) values(#{username}, #{password}, #{avatar})")
    Integer register(User user);

    @Update("update user set avatar = #{avatar} where id = #{id}")
    Integer avatar(User user);

    @Select("select * from user where id = #{id} and admin = 1")
    User admin(Integer id);

    @Select("select username, avatar from user where id = #{id}")
    User getUsername(Integer id);
}